
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>后台</title>
<link rel="stylesheet" href="public/admin/dashicons.css">
<link rel="stylesheet" href="public/admin/style.css">
<script src="public/admin/jquery.min.js"></script>
</head>
<body>
<div class="wrap wrap-comment">
<h1>评论管理</h1>
<div class="tips"></div>
<div class="box">
<div class="box-body">
	<div class="jq-loading">正在进行通信…</div>
	<table class="c-each">
				<tr><td class="c-each-del"><a href="/?p=admin&c=comment&exec=del&id=5&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			<td class="c-each-user">
				<a class="s-avatar" href="#"><img src="public/avatar/2016-06/17/54313264983c16905def7669f32fbb1a.jpg" alt="用户头像"></a>
				<span><a href="#">test3</a></span>
			</td>
			<td class="c-each-content">
				<span>发表时间：2016-06-17 10:43:01　发表于：<a href="/?c=course&id=3" target="_blank">Linux网络流媒体服务器</a></span>
				<p>讲师好nice啊。。。</p>
				<input type="text" name="reply_5" placeholder="请输入管理员回复" value="">
				<input type="button" class="jq-btn" data-id="5" data-url="/?p=admin&c=comment&a=ajaxreply&id=5" value="回复">
			</td>
		</tr>
				<tr><td class="c-each-del"><a href="/?p=admin&c=comment&exec=del&id=4&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			<td class="c-each-user">
				<a class="s-avatar" href="#"><img src="public/avatar/2016-06/17/eb5a3608421c409493db18ed353737ab.jpg" alt="用户头像"></a>
				<span><a href="#">test1</a></span>
			</td>
			<td class="c-each-content">
				<span>发表时间：2016-06-17 10:37:19　发表于：<a href="/?c=course&id=3" target="_blank">Linux网络流媒体服务器</a></span>
				<p>通俗易懂，值。。。。</p>
				<input type="text" name="reply_4" placeholder="请输入管理员回复" value="">
				<input type="button" class="jq-btn" data-id="4" data-url="/?p=admin&c=comment&a=ajaxreply&id=4" value="回复">
			</td>
		</tr>
				<tr><td class="c-each-del"><a href="/?p=admin&c=comment&exec=del&id=3&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			<td class="c-each-user">
				<a class="s-avatar" href="#"><img src="public/avatar/2016-06/17/ea7c0f284f9a1ae0352795862634d69a.jpg" alt="用户头像"></a>
				<span><a href="#">test2</a></span>
			</td>
			<td class="c-each-content">
				<span>发表时间：2016-06-17 10:36:04　发表于：<a href="/?c=course&id=3" target="_blank">Linux网络流媒体服务器</a></span>
				<p>哇哦，秒懂</p>
				<input type="text" name="reply_3" placeholder="请输入管理员回复" value="">
				<input type="button" class="jq-btn" data-id="3" data-url="/?p=admin&c=comment&a=ajaxreply&id=3" value="回复">
			</td>
		</tr>
				<tr><td class="c-each-del"><a href="/?p=admin&c=comment&exec=del&id=2&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			<td class="c-each-user">
				<a class="s-avatar" href="#"><img src="public/avatar/2016-06/17/ea7c0f284f9a1ae0352795862634d69a.jpg" alt="用户头像"></a>
				<span><a href="#">test2</a></span>
			</td>
			<td class="c-each-content">
				<span>发表时间：2016-06-17 10:34:27　发表于：<a href="/?c=course&id=2" target="_blank">HTML5微场景应用</a></span>
				<p>讲师好nice啊，么么哒~~~</p>
				<input type="text" name="reply_2" placeholder="请输入管理员回复" value="">
				<input type="button" class="jq-btn" data-id="2" data-url="/?p=admin&c=comment&a=ajaxreply&id=2" value="回复">
			</td>
		</tr>
				<tr><td class="c-each-del"><a href="/?p=admin&c=comment&exec=del&id=1&token=c15a2f6833d839516c2d95b4ce48456b" class="jq-del">删除</a></td>
			<td class="c-each-user">
				<a class="s-avatar" href="#"><img src="public/avatar/2016-06/17/54313264983c16905def7669f32fbb1a.jpg" alt="用户头像"></a>
				<span><a href="#">test3</a></span>
			</td>
			<td class="c-each-content">
				<span>发表时间：2016-06-17 10:33:12　发表于：<a href="/?c=course&id=2" target="_blank">HTML5微场景应用</a></span>
				<p>讲的通俗易懂，喵喵~~</p>
				<input type="text" name="reply_1" placeholder="请输入管理员回复" value="">
				<input type="button" class="jq-btn" data-id="1" data-url="/?p=admin&c=comment&a=ajaxreply&id=1" value="回复">
			</td>
		</tr>
			</table>
</div>
</div>
<div class="pagelist"></div>
</div>
<script>
//回复评论
$(".jq-btn").click(function(){
	//获取待回复的评论的ID
	var id = $(this).attr("data-id");
	//获取指定ID的回复内容
	var comment = $('input[name=reply_'+id+']').val();
	if($.trim(comment).length < 1){
		alert("请填写回复内容。");
		return false;
	}
	//禁用按钮，防止重复提交
	$(this).attr("disabled", "disabled");
	//显示通信提示（图片）
	$(".jq-loading").show();
	//获取提交的URL地址
	var url = $(this).attr("data-url")+ '&token=c15a2f6833d839516c2d95b4ce48456b';
	//发送Ajax请求
	var response = null;
	$.ajax({
		"url": url,			//目标地址
		"type": "POST",		//请求方式
		"dataType": "json",	//Ajax交互的数据类型
		"data": {"reply": comment},  //发送的数据
		"success": function(msg){    //success优先于complete调用（如果服务器返回的不是json，那么success不会执行）
			response = msg;
		},
		"complete": function(xhr){
			//隐藏通信提示
			$(".jq-loading").hide();
			//提示信息
			alert(response===null ? "执行失败：服务器异常" : (response.ok ? "管理员回复成功！" : response.data));
			//恢复按钮
			$(".jq-btn").removeAttr("disabled");
		}
	});
});
//删除前提示
$(".jq-del").click(function(){
    return confirm("您确定要删除此评论吗？");
});
</script>
</body>
</html>